#define _CRT_SECURE_NO_WARNINGS

template <class T>
struct Node
{
	T data;
	Node* _prev;
	Node* _next;
};

template<class T, class Ref, class Ptr>
struct iterator
{
	typedef Node<T> node;
	typedef iterator<T,Ref,Ptr> Self;
	iterator(node* it)
		:_node(it)
	{

	}
	bool operator!=(Self &it)
	{
		return it._node != node;
	}
	bool operator==(Self& it)
	{
		return it._node == node;
	}
	Self& operator++()
	{
		_node = _node->_next;
		return *this;
	}
	Self operator++(int)
	{
		Self tmp(*this);
		_node = _node->_next;
		return tmp;
	}
	Self& operator--()
	{
		_node = _node->_prev;
		return *this;
	}
	Self operator--(int)
	{
		Self tmp(*this);
		_node = _node->_prev;
		return tmp;
	}
	Ref operator*()
	{
		return _node->_data;
	}
	Ptr operator->()
	{
		return &(_node->_data);
	}
private:
	node* _node;
};